function getPolice(username,callback) {
  wx.cloud.callFunction({
    name: 'get_police',
    data: {
      username: username
    },
    success: function (res) {
      callback && callback(res.result)
    },
    fail: console.error
  })
}

function getInfoByid(id, callback) {
  wx.cloud.callFunction({
    name: 'get_info_byid',
    data: {
      id: id
    },
    success: function (res) {
      callback && callback(res.result)
    },
    fail: console.error
  })
}

function submitInOut(info, callback) {
  wx.cloud.callFunction({
    name: 'submit_inout',
    data: info,
    success: function (res) {
      callback && callback(res.result)
    },
    fail: console.error
  })
}

function getInOut(callback) {
  wx.cloud.callFunction({
    name: 'get_inout',
    success: function (res) {
      callback && callback(res.result)
    },
    fail: console.error
  })
}

function getInOutByid(id, callback) {
  wx.cloud.callFunction({
    name: 'get_inout_byid',
    data: {
      id: id
    },
    success: function (res) {
      callback && callback(res.result)
    },
    fail: console.error
  })
}

function teacherReg(info, callback) {
  wx.cloud.callFunction({
    name: 'teacher_reg',
    data: info,
    success: function (res) {
      callback && callback(res.result)
    },
    fail: console.error
  })
}

function getTeacherByid(teacherID, callback) {
  wx.cloud.callFunction({
    name: 'get_teacher_byid',
    data: {
      teacherID: teacherID
    },
    success: function (res) {
      callback && callback(res.result)
    },
    fail: console.error
  })
}

function getStudentOppenid(studentID,callback){
  wx.cloud.callFunction({
    name:'get_student_openid',
    data:{
      studentID:studentID
    },success:function(res){
      callback&&callback(res.result)
    },
    fail:console.error
  })
}

function addOpenid(studentID, callback) {
  wx.cloud.callFunction({
    name: 'addopenid',
    data: {
      studentID: studentID
    }, success: function (res) {
      callback && callback(res.result)
    },
    fail: console.error
  })
}


module.exports = {
  getPolice:getPolice,
  getInfoByid: getInfoByid,
  submitInOut: submitInOut,
  getInOut: getInOut,
  getInOutByid: getInOutByid,
  teacherReg: teacherReg,
  getTeacherByid: getTeacherByid,
  getStudentOppenid: getStudentOppenid,
  addOpenid: addOpenid,
}